import os
import fmt
import path
import elf
import libc_temp
import dirent_temp
import strings

var a1 = path.join('/test/hello/world/', './nice.tar.gz')
println(a1)
var a2 = path.join('/test/hello/world', './nice.tar.gz')
println(a2)
var a3 = path.join('/test/hello/world', 'nice.tar.gz')
println(a3)

var s = libc_string_replace('/test/hello/world/sub/sub2', '/test/hello/world/', '')
println(s)

// test list dir (build in fn?) parser handle?
var size = 12 + sizeof(dirent_t) - 24
println('dirent_t size', size)
var list = os.listdir('mock')
println("os.listdir of mock len", list.len)
for v in list {
    println('item: ', v)
}

// path.dir
println(path.dir('/test/hello'))
println(path.dir('/test/hello/'))
println(path.dir('/test'))
println(path.dir('test'))
println(path.dir(''))

println(path.exists('./mock'))
println(path.exists('./mock/stat.txt'))
println(path.exists('notfound.txt'))


// elf.arch
var arch = elf.arch('mock/file')
println('mock/file elf arch is', arch)

// path.base
println('path.base----------------------')
println(path.base('/test/hello'))
println(path.base('/test/hello/'))
println(path.base('/test/hello//'))
println(path.base('/test'))
println(path.base('test'))
println(path.base(''))
println(path.base('/'))
println(path.base('//'))

// sprintf
fmt.printf('!%s!%s%s', 'test str', '', 'hello')